import request from "@/utils/request";

export const getArticles = params => request({
    method: 'GET',
    url: '/v1_0/articles',
    params
})

export const getArticleById = id => {
    return request({
        url: `/v1_0/articles/${id}`
    })
}

// 封装利用id调收藏文章接口的函数
export const addCollect = id => request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
        target: id
    }
})

// 封装利用id调取消文章收藏接口的函数
export const deleteCollect = id => request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${id}`
})

export const addLike = id => request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
        target: id
    }
})

export const deleteLike = id => request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${id}`
})